<script setup lang="ts">
import  post  from "@/lib/post.ts";

import { ElMessageBox } from "element-plus";
import { ref } from "vue";

const option = ref(null); // 折线图

const getCreateTimeStatics = async () => {
  const data = await post("/statics/member", { groupKey: "name" });
  if (!data.success) {
    return ElMessageBox.alert(data.message);
  }
  const list = data.result.list;
  const values = list.map((o) => o.value); // 数值
  const labels = list.map((o) => o.label); // 标签的值（x轴的标签）

  option.value = {
    xAxis: {
      type: "category",
      data: labels,
    },
    yAxis: {
      type: "value",
    },
    series: [
      {
        data: values,
        type: "line",
      },
    ],
  };
};

getCreateTimeStatics();
</script>

<template>
  <v-chart :option="option" />
</template>
